package com.fndsoft.zheshangmeap.view;

import android.app.Activity;
import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.LinearLayout;

/**
 * 自定义的view
 * 
 * @author carlos carlosk@163.com
 * @version 创建时间：2013年10月28日 上午10:30:52
 */
public class MeapDialog extends Dialog {
	public MeapDialog(View view, Activity currentActivity) {
		super(currentActivity);
		LayoutParams lp = getWindow().getAttributes();
		// lp.width = PhoneUtil.getScreenWidth() - 200;
		lp.gravity = Gravity.CENTER;
		lp.dimAmount = 0;
		lp.flags = LayoutParams.FLAG_LAYOUT_NO_LIMITS
				| LayoutParams.FLAG_NOT_TOUCH_MODAL;
		setCanceledOnTouchOutside(false);
		getWindow().setAttributes(lp);
		getWindow().setBackgroundDrawable(
				new ColorDrawable(android.graphics.Color.TRANSPARENT));

		// 在view里面增加一层全屏透明的LinearLayout
		LinearLayout llay = new LinearLayout(currentActivity);
		llay.setGravity(Gravity.CENTER);
		llay.setBackgroundDrawable(new ColorDrawable(
				android.graphics.Color.TRANSPARENT));
		llay.addView(view);

		LayoutParams llayLp = new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.MATCH_PARENT);
		// 获取屏幕的长宽
		DisplayMetrics dm = new DisplayMetrics();
		getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
		llayLp.width = dm.widthPixels;
		llayLp.height = dm.heightPixels;

		setContentView(llay, llayLp);
	}
}
